// -----------------------------------------------------------------------
//  <copyright file="UserConfiguration.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://www.dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024-05-10 17:05</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Identity.Domain.Entities;


namespace DaprPlus.Identity.Infrastructure.EntityFrameworkCore.Configurations;

public class UserConfiguration : EntityConfigurationBase<User>
{
    public override void Configure(EntityTypeBuilder<User> builder)
    {
        builder.Property(m => m.DeletedTime).ValueGeneratedOnAdd().HasDefaultValue(DateTime.MinValue);
        builder.Property(m => m.ConcurrencyStamp).IsConcurrencyToken();

        builder.HasIndex(m => new { m.NormalizedUserName, m.DeletedTime }).HasDatabaseName("UserNameIndex").IsUnique();
        builder.HasIndex(m => new { m.NormalizedEmail, m.DeletedTime }).HasDatabaseName("UserEmailIndex").IsUnique();
    }
}
